package com.aquan.map_jetpack.ui.components.bottom


import androidx.compose.foundation.layout.*
import androidx.compose.foundation.lazy.grid.GridCells
import androidx.compose.foundation.lazy.grid.LazyVerticalGrid
import androidx.compose.foundation.lazy.grid.items
import androidx.compose.material.Icon
import androidx.compose.material.Text
import androidx.compose.material.icons.Icons
import androidx.compose.material.icons.filled.More
import androidx.compose.material.icons.filled.Person
import androidx.compose.runtime.Composable
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.text.font.FontWeight
import androidx.compose.ui.tooling.preview.Preview
import androidx.compose.ui.unit.dp
import androidx.compose.ui.unit.sp
import com.aquan.map_jetpack.model.entity.card.CardItem
import com.aquan.map_jetpack.ui.components.card.TopNameBottomValCard
import kotlin.math.ceil


@Composable
fun BottomContent() {
    val dataList = listOf(
        DataListItem(name = "路段编码", field = "lxbm", value = "S41430000"),
        DataListItem(name = "路线名称", field = "lxbm", value = "长沙-湘潭西线高速公路"),
        DataListItem(name = "七点桩号", field = "lxbm", value = "0.78"),
        DataListItem(name = "讫点桩号", field = "lxbm", value = "21.421"),
        DataListItem(name = "路段里程", field = "lxbm", value = "20.641")
    )
    Box(
        modifier = Modifier
            .padding(5.dp)
    ) {
        Column(modifier = Modifier) {
            // 头部的标题内容
            Row(
                modifier = Modifier
                    .fillMaxWidth()
                    .padding(bottom = 10.dp),
                horizontalArrangement = Arrangement.SpaceBetween,
                verticalAlignment = Alignment.CenterVertically

            ) {
                Text(
                    text = "湖南长沙高速公路有限公司",
                    fontSize = 14.sp,
                    color = Color.Black,
                    fontWeight = FontWeight.Bold
                )
                Row(
                    modifier = Modifier,
                    verticalAlignment = Alignment.CenterVertically
                ) {
                    Icon(
                        modifier = Modifier
                            .height(10.dp),
                        imageVector = Icons.Default.More,
                        contentDescription = null,
                        tint = Color.Blue
                    )
                    Text(
                        text = "查看更多",
                        fontSize = 10.sp,
                        color = Color.Blue,
                    )
                }

            }


            LazyVerticalGrid(
                columns = GridCells.Fixed(2)
            ) {
                items(dataList) {
                    TopNameBottomValCard(
                        dataCard = CardItem(
                            name = it.name,
                            value = it.value
                        )
                    )
                }
            }
        }
    }
}

data class DataListItem(val name: String, val value: String = "", val field: String)

@Preview
@Composable
fun BottomContentPreview() {
    BottomContent()
}

